/*
 * Function.cpp
 *
 *  Created on: 2011/06/22
 *      Author: naoki
 */

#include "NTEngine/NTEngine.h"
#include "NTEngine/Math/Function.h"
#include <cmath>

namespace NTEngine {
namespace Math {

const float PI = 3.1415926535897932384626433832795f;
const float PI2 = PI * 2.0; /// 2π

static const float TO_RADIAN = PI / 180.0;
static const float TO_DEGREES = 180.0 / PI;

float toRadian( float deg ) {
	return TO_RADIAN * deg;
}

float toDegrees( float rad ) {
	return TO_DEGREES * rad;
}

float sin( float a ) {
	return ::sinf( a );
}

float cos( float a ) {
	return ::cosf( a );
}

float tan( float a ) {
	return ::tanf( a );
}

float asin( float a ) {
	ASSERT( ( a >= -1.f ) && ( a <= 1.f ) );
	return ::asinf( a );
}

float acos( float a ) {
	ASSERT( ( a >= -1.f ) && ( a <= 1.f ) );
	return ::acosf( a );
}

float atan( float a ) {
	return ::atanf( a );
}

float atan2( float y, float x ) {
	return ::atan2f( y, x );
}

float pow( float a, float b ) {
	return ::powf( a, b );
}

float abs( float a ) {
	return ( a < 0 ) ? -a : a;
}

float min( float a, float b ) {
	return ( a < b ) ? a : b;
}

float max( float a, float b ) {
	return ( a > b ) ? a : b;
}

float sqrt( float a ) {
	ASSERT( a >= 0.F );
	return ::sqrtf( a );
}

float fabs( float a ) {
	return ::fabsf( a );
}

} // namespace Math
} //namespace NTEngine
